package net.mingsoft.cms.util;

import net.mingsoft.basic.util.ApplicationContextUtil;
import net.mingsoft.cms.biz.impl.ContentBizImpl;
import net.mingsoft.examine.utils.BlankUtil;
import net.mingsoft.examine.utils.DateUtil;

/**
 * 报告编号（形如BG20220602001）工具类
 *
 * @author gengfa
 * @date 2022/06/02
 */
public class ContentCodeUtil {
    private ContentCodeUtil() {
    }

    public static String getCode() {
        String date = DateUtil.getYmdDateCN(DateUtil.getCurrDate(DateUtil.FORMAT_ONE));
        ContentBizImpl contentBiz =
                (ContentBizImpl) ApplicationContextUtil.getApplicationContext().getBean("cmscontentBizImpl");
        String maxCode = contentBiz.getMaxCode(date);
        if (BlankUtil.isBlank(maxCode)) {
            return date + "001";
        }
        return String.valueOf(Long.parseLong(maxCode) + 1);
    }
}
